<?php
require_once '../sub/init.php';
if(!is_mobile())header("Location: ".Href('loveb'));
$currfields = 'sex,grade,loveb,sign_time,openid,subscribe,money';
require_once ZEAI.'m/my_chk_u.php';
require_once ZEAI.'cache/config_vip.php';
require_once ZEAI.'cache/udata.php';
$t = (ifint($t,'1-3','1'))?$t:1;
$cook_grade = intval($row['grade']);
$cook_sex   = intval($row['sex']);
$cook_loveb = intval($row['loveb']);
$cook_money = $row['money'];
$cook_sign_time= $row['sign_time'];
if ($submitok=='ajax_sign'){
	if($_VIP['sign_numlist']=='0')json_exit(array('flag'=>0,'num'=>0,'msg'=>'Fobidden'));
	$sign_time  = $cook_sign_time;
	$data_openid= $row['openid'];
	$data_subscribe= $row['subscribe'];
	$old_time = YmdHis($sign_time,"Ymd");
	$now_time = YmdHis(ADDTIME,"Ymd");
	if($now_time==$old_time)json_exit(array('flag'=>0,'msg'=>'~您今天已领过了~　请明天再来'));
	if($now_time>$old_time || $sign_time==0){
		$endip     = getip();
		$arry      = json_decode($_VIP['sign_numlist'],true);;
		$randloveb = $arry[array_rand($arry,1)];
		$db->query("UPDATE ".__TBL_USER__." SET loveb=loveb+$randloveb,sign_time=".ADDTIME.",logincount=logincount+1,endtime=".ADDTIME.",endip='$endip' WHERE id=".$cook_uid);
		$db->AddLovebRmbList($cook_uid,'每日签到（手机）',$randloveb,'loveb',7);		
		//站内消息
		$C = $cook_nickname.'您好，您有一笔'.$_ZEAI['loveB'].'到账！　<a href='.a('{"kind":"loveb","mp":"pc"}').' class=aHUI>查看详情</a>';
		$db->SendTip($cook_uid,'每日签到',dataIO($C,'in'),'sys');
		//爱豆到账提醒
		if (!empty($data_openid) && $data_subscribe==1){
			$F = urlencode($cook_nickname."您好，您有一笔".$_ZEAI['loveB']."到账！");
			$C = urlencode('每日签到，恭喜你，再接再励哦~~');
			@wx_mb_sent('mbbh=ZEAI_ACCOUNT_IN&openid='.$data_openid.'&num='.$randloveb.'&first='.$F.'&content='.$C.'&url='.a('{"kind":"loveb","mp":"mob"}'));
		}
		$chkflag = 1;
	}else{
		$chkflag = 0;
	}
	json_exit(array('flag'=>$chkflag,'num'=>$randloveb,'msg'=>'~您今天已领过了~　请明天再来哦'));
}
if($t == 2){
	function rows_ulist($rows,$p) {
		global $_ZEAI;
		$id       = $rows['id'];
		$content  = dataIO($rows['content'],'out');
		$num      = $rows['num'];
		$addtime  = YmdHis($rows['addtime']);
		if ($num<0){$numstyle = "fs";}else{$numstyle = "zs";$num = '+'.$num;}
		$O = '<dl><dt>'.$content.'<font>'.$addtime.'</font></dt><dd class="'.$numstyle.'">'.$num.'</dd></dl>';
		return $O;
	}
	$nodatatips="<div class='nodatatips'><i class='ico'>&#xe608;</i>暂时木有内容呀～～</div>";
	$_ZEAI['pagesize'] = 15;
	$ZEAI_SQL = "uid=".$cook_uid;
	$ZEAI_SELECT="SELECT id,content,num,addtime FROM ".__TBL_LOVEB_LIST__." WHERE  ".$ZEAI_SQL." ORDER BY id DESC";
	if($submitok=='ZEAI_list'){exit(Zeai_ajax_list_fn($ZEAI_totalP,$p));}
	$ZEAI_total = $db->COUNT(__TBL_LOVEB_LIST__,$ZEAI_SQL);
	$ZEAI_totalP= ceil($ZEAI_total/$_ZEAI['pagesize']);
}
$urolenew = json_decode($_ZEAI['urole'],true);
$newarr=array();foreach($urolenew as $RV){if($RV['f']==1){$newarr[]=$RV;}else{continue;}}
$newarr=encode_json($newarr);
$urole = json_decode($newarr);
$contact_loveb = json_decode($_VIP['contact_loveb']);
$contact_daylooknum = json_decode($_VIP['contact_daylooknum']);
$chat_loveb    = json_decode($_VIP['chat_loveb']);
$chat_daylooknum = json_decode($_VIP['chat_daylooknum']);
$loveb_buy     = json_decode($_VIP['loveb_buy'],true);
$signflag = 1;
if($cook_sign_time>0){
	$old_time = YmdHis($cook_sign_time,"Ymd");
	$now_time = YmdHis(ADDTIME,"Ymd");
	if($now_time==$old_time)$signflag = 0;
}
if($_VIP['sign_numlist']=='0')$signflag = 0;
$nav='my';?>
<!doctype html><html><head><meta charset="utf-8">
<title>我的-<?php echo $_ZEAI['siteName'];?></title>
<?php echo HEADMETA; ?>
<link href="<?php echo RES;?>m/css/m.css?<?php echo $_ZEAI['cache_str'];?>" rel="stylesheet" type="text/css" />
<link href="<?php echo RES;?>m/css/my_loveb_money.css?<?php echo $_ZEAI['cache_str'];?>" rel="stylesheet" type="text/css" />
<link href="<?php echo HOST;?>/cache/zeaicolor.css?<?php echo $_ZEAI['cache_str'];?>" rel="stylesheet" type="text/css" />
<script src="<?php echo RES;?>www_zeai_cn.js?<?php echo $_ZEAI['cache_str'];?>"></script>
<script src="<?php echo RES;?>m/js/m.js?<?php echo $_ZEAI['cache_str'];?>"></script>
<style>
.my_loveb_ye .LoveB:before{content:'当前<?php echo $_ZEAI['loveB']; ?>';}
.my_loveb_ye .LoveB{color:<?php echo $_ZEAI['mob_mbcolor'];?>;}
.my_loveb_ye .box .dt i{color:<?php echo $_ZEAI['mob_mbcolor'];?>}
.nextbtn{box-shadow:0 .3rem .8rem rgba(<?php echo c16_rgb($_ZEAI['mob_mbcolor']);?>,.4);background-color:#fff;background:-webkit-linear-gradient(315deg,rgba(<?php echo c16_rgb($_ZEAI['mob_mbcolor']);?>,.6) 0%,<?php echo $_ZEAI['mob_mbcolor'];?> 100%)}
.tabmenu a.ed:after{background-color:<?php echo $_ZEAI['mob_mbcolor'];?>}
header.bgcolor{background-color:<?php echo $_ZEAI['mob_mbcolor'];?>}
#backtop a{color:<?php echo $_ZEAI['mob_mbcolor'];?>;background-color:#fff}
<?php
if ($_ZEAI['m_mb']==2){
	echo '.TRnav_btn i{color:'.$_ZEAI['mob_mbcolor'].'}';
	echo '.tabmenufix{width:60%;max-width:500px;top:1.5rem;margin:auto;left:0;right:0}';
	
	$padding_top = ($signflag == 0)?'5rem':'.8rem';
	echo '.my_loveb_ye{padding-top:'.$padding_top.'}';
	echo '.my_loveb_mx{padding-top:5rem}';
	echo '.my_loveb_cz{padding-top:9rem}';

	$mini_class='top_mini4';
}else{
	$padding_top = ($signflag == 0)?'8.8rem':'.8rem';
	echo '.my_loveb_ye{padding-top:'.$padding_top.'}';
	$mini_class='top_mini4 zeaibg bgcolor yunbox';
}
?>
</style>
</head>
<body>
<?php
$mini_href ='zeai.openurl(\'my.php\');';
$mini_title='我的'.$_ZEAI['loveB'].'账户';
require_once ZEAI.'m/top_mini.php';?>
<div class="tabmenu tabmenu<?php echo ($_VIP['loveb_czlist']=='0')?2:3;?> tabmenufix">
	<a href="my_loveb.php?t=1"<?php echo ($t == 1)?' class="ed"':'';?>>余额</a>
	<a href="my_loveb.php?t=2"<?php echo ($t == 2)?' class="ed"':'';?>>明细</a>
	<?php if(str_len($_VIP['loveb_czlist'])>2){?><a href="my_loveb.php?t=3"<?php echo ($t == 3)?' class="ed"':'';?>>充值</a><?php }?>
</div>
<!--*********爱豆余额*********-->
<?php switch ($t){case 1:?>
	<?php if ($signflag == 1){?>
	<div class="clear"></div>
	<div class="qdbox" id="sign">
    	<a><i class="ico">&#xe64b;</i></a>
    	<span id="qdspan">签到</span>
        <div class="signbox" id="signbox"><div class="sign_gif rotate"></div></div>
    </div>
	<?php }?>
    <div class="my_loveb_ye">
        <div class="box">
            <div class="dt"><i class="ico">&#xe618;</i></div>
            <div class="dd"><span class="LoveB" id="LoveB"><?php echo $cook_loveb; ?><font>个</font></span></div>
        </div>
        <div class="clear"></div>
        <div class="loveBdetail">
            ● 可以用来参与冒泡置顶排名　<a href="my_refresh.php" class="btn size1 BAI yuan">我要冒泡</a><br>
            <?php if(in_array('gift',$navarr)){?>● 可以用来赠送对方礼物<br><?php }?>
            <?php if(in_array('contact',$navarr)){?>● 可以解锁对方联系方式　<a class="btn size1 BAI yuan" onClick="ZeaiM.div2({obj:my_loveb_contactHelp,title:'解锁联系方式费用说明',w:30,h:32});">使用说明</a><br><?php }?>
            <?php if(in_array('chat',$navarr)){?>● 解锁查看回复信件/聊天　<a class="btn size1 BAI yuan" onClick="ZeaiM.div2({obj:my_loveb_chathelp,title:'解锁聊天费用说明',w:30,h:32});">使用说明</a><br><?php }?>
            <br>
            <a href="c.php?submitok=my_loveb_getTip" class="btn yuan size4 nextbtn">如何获得<?php echo $_ZEAI['loveB']; ?>？</a>
        </div>
    </div>
    
    <!--helpDiv Start-->
    <div id="my_loveb_contactHelp" class="helpDiv">
        <ul>
        <?php
        foreach ($urole as $uv) {
            $grade = $uv->g;
            $title = $uv->t;
            $num   = $contact_loveb->$grade;
			if($contact_daylooknum->$grade==0){
				$num_str = ' 无权查看';
			}else{
				$num_str = ($num>0)?' <font class="Cf00">'.$num.'</font> '.$_ZEAI['loveB'].'/人':' 免费查看';
			}
            if($cook_grade==$grade){
                $ifmy = '　<font class="Cf00">（我）</font>';
                $myclkB=$num;
            }else{
                $ifmy = '';
            }
            $out1 .= '<li>'.uicon_grade_all($grade,1,$cook_sex).' '.$title.' <i class="ico">&#xe62d;</i>'.$num_str.$ifmy.'</li>';
            }echo $out1;
        ?>
        </ul>
        <a href="my_vip.php" class="btn size3 zeaibg vipbtn yuan"><i class="ico">&#xe6ab;</i> 立即升级</a>
    </div>
    <div id="my_loveb_chathelp" class="helpDiv">
        <ul>
        <?php
        foreach ($urole as $uv) {
            $grade = $uv->g;
            $title = $uv->t;
            $num   = $chat_loveb->$grade;
			if($chat_daylooknum->$grade==0){
				$num_str = ' 无权聊天';
			}else{
				$num_str = ($num>0)?' <font class="Cf00">'.$num.'</font> '.$_ZEAI['loveB'].'/人':' 免费聊天';
			}
            if($cook_grade==$grade){
                $ifmy = '　<font class="Cf00">（我）</font>';
                $myclkB=$num;
            }else{
                $ifmy = '';
            }
            $out2 .= '<li>'.uicon_grade_all($grade,1,$cook_sex).' '.$title.' <i class="ico">&#xe62d;</i>'.$num_str.$ifmy.'</li>';
        }echo $out2;
        ?>
        </ul>
        <a href="my_vip.php" class="btn size3 zeaibg vipbtn yuan"><i class="ico">&#xe6ab;</i> 立即升级</a>
    </div>
    <!--helpDiv End-->
    <?php if ($signflag == 1){?>
    <div id="mask_sign" class='alpha0_100'><div class="gif rotate" id="mask_gif"></div></div>
    <div id="signokbox" class="scale">
        <div class="signok">
            <h1>好手气</h1>
            <div class="hr"></div>
            <h4>获得<font id="randloveb">0</font>个<?php echo $_ZEAI['loveB'];?></h4>
        </div>
    </div>
	<script>
    o('sign').onclick = function(){sign('my'+zeai.extname);}
    o('mask_sign').onclick = function(){ZEAI_signclose();}
    o('signokbox').onclick = function(){ZEAI_signclose();}
    function ZEAI_signclose(){zeai.showSwitch('mask_sign,signokbox');setTimeout(function(){o('sign').addClass('qdboxtopmove');},500);}
    function sign(url){
        zeai.ajax({'url':'my_loveb'+zeai.extname,'data':{submitok:'ajax_sign'}},function(e){var rs=zeai.jsoneval(e);
            if (rs.flag==1){
                zeai.showSwitch('mask_sign,signokbox,mask_gif');
                randloveb.html(rs.num);
                setTimeout(function(){if(!zeai.empty(o('LoveB')))o('LoveB').html((parseInt(o('LoveB').innerHTML)+parseInt(rs.num))+'<font>个</font>');},3000);
                qdspan.html('已签到');
            }else{zeai.msg(rs.msg);}
            if (!zeai.empty(o('signbox')))o('signbox').remove();
        });	
    }
    </script>
    <?php }?>
    
<!--*********明细*********-->
<?php break;case 2:?>
    <div class="my_loveb_mx" id="ZEAI_list"><?php if($ZEAI_totalP>0){echo Zeai_ajax_list_fn($ZEAI_totalP,$p);}else{echo $nodatatips;}?></div>
    <script>
    <?php
    if ($ZEAI_total > $_ZEAI['pagesize']){?>
    var ZEAI_totalP = parseInt(<?php echo $ZEAI_totalP; ?>),p=2;
    zeaiOnscroll_json={url:'my_loveb'+zeai.extname,data:{submitok:'ZEAI_list',ZEAI_totalP:ZEAI_totalP,t:2}};
    document.body.onscroll = zeaiOnscroll;
    <?php }?>
    </script>
	<div id="backtop"><a href="#top" id="btmTopBtn"><i class="ico">&#xe60c;</i>顶部</a></div>
<!--*********充值*********-->
<?php break;case 3:
	if($_VIP['loveb_czlist']=='0')exit('<div class="nodatatips">充值已关闭</div>');?>
	<style>.my_loveb_cz dl dd em.ed{background-color:rgba(<?php echo c16_rgb($_ZEAI['mob_mbcolor']);?>,.1);color:<?php echo $_ZEAI['mob_mbcolor'];?>}</style>
    <form id="zeaiFORM" class="my_loveb_cz">
    <dl>
        <dt>充值数量</dt>
        <dd id="numlist">
        	<?php
			$ARR = json_decode($_VIP['loveb_czlist'],true);;
			if (@count($ARR) >= 1 && is_array($ARR)){
				foreach ($ARR as $k=>$bV) {
					$cls=($k==0)?' class="ed"':'';
					$V=round($bV/$_ZEAI['loveBrate'],2);
					echo '<em rmb="'.$V.'"'.$cls.'>'.$bV.'个</em>';
				}
			}
			?>
        </dd>
    </dl>
    <dl class="rmbdl"><dt>应付金额</dt><dd><span id="price"></span><span id="pricetitle"></span></dd></dl>
    <div style="text-align:center;margin:20px auto"><button type="button" class="btn size4 nextbtn zeaibg" id="nextbtn">下一步</button></div>
    <?php
		$jump_url = (!empty($jumpurl))?urldecode($jumpurl):HOST.'/m/my_loveb.php';
		$money = 0;
		$kind  = 2;
		echo '<input type="hidden" id="money" value="'.$money.'">';
	?>
    <div class="linebox">
        <div class="line W50"></div>
        <div class="title BAI S14" style="background-color:#fff">优惠信息</div>
    </div>
    <div class="tips">
        <?php
        foreach ($urole as $uv) {
            $grade = $uv->g;
            $title = $uv->t;
			if($uv->f == 0)continue;
            $str = $loveb_buy[$grade];
            $str = ($str >= 1)?'原价':10*$str.'折';
            $out3 .= uicon_grade_all($grade,1,$cook_sex).$title.' <i class="ico">&#xe62d;</i> <font class="C999">'.$str.'</font><br>';
        }echo $out3;
        ?>
        <a href="my_vip.php" class="btn size2 BAI yuan"><i class="ico">&#xe6ab;</i> 我要升级</a>
    </div>
    </form>
	<script>
	var loveBzk = <?php echo $loveb_buy[$cook_grade];?>;
	var czlist  = numlist.getElementsByTagName("em");
    zeai.listEach(czlist,function(obj){
		if (obj.hasClass('ed')){priceInit(obj);}
		obj.onclick=function(){priceInit(obj);cleardom(obj);}
	});
	function priceInit(obj){
		var rmb=obj.getAttribute("rmb");
		var endrmb=rmb*loveBzk;
		//endrmb=endrmb.toFixed(2);
		endrmb=returnFloat(endrmb);
		o('money').value = endrmb;
		price.html(endrmb+'元');
		var tt = '';
		if(loveBzk < 1)tt=' （'+loveBzk*10+'折优惠<s>原价'+rmb+'元</s>）';
		pricetitle.html(tt);
	}
	function cleardom(curdom){
		zeai.listEach(czlist,function(obj){obj.removeClass('ed');});
		curdom.addClass('ed');
	}
	nextbtn.onclick=function(){
		if (o('money').value<=0){zeai.msg('请选择');return false;}
		money=o('money').value;o('money_str').html(money+'元');
		ZeaiM.div_up({obj:czbox,h:<?php echo (is_weixin())?30.5:37.5;?>});
	}
	function returnFloat(value){
		var value=Math.round(parseFloat(value)*100)/100;
		var xsd=value.toString().split(".");
		if(xsd.length==1){
			value=value.toString()+".00";
			return value;
		}
		if(xsd.length>1){
			if(xsd[1].length<2){
				value=value.toString()+"0";
			}
			return value;
		}
	}
    </script><?php
	require_once 'my_pay.php';
break;}
if($_ZEAI['m_mb']==2){
	require_once ZEAI.'m/bottom2.php';
}else{
	require_once ZEAI.'m/TRnav.php';
	require_once ZEAI.'m/bottom.php';
}
?>